<button onclick="downloadExcel()">下载excel</button>
<script>
    const download = (data, name) => {
        const a = document.createElement('a')
        const result = data.map(v => {
            return Object.values(v).join('\t')
        }).join('\n')
        a.href = URL.createObjectURL(new Blob([result]))
        a.setAttribute('download', name)
        a.click()
    }
    const downloadExcel = () => {
        download([
            {id: 'ID', name: '姓名', age: '年龄'},
            {id: 1, name: '章三', age: 22},
            {id: 2, name: '里斯', age: 23},
            {id: 3, name: '王武', age: 24}
        ], '用户信息.xls')
    }
</script>